/**
 * Created by Freeman on 2016/8/3.
 */
import React, {Component, PropTypes} from 'react'
import { bindActionCreators } from 'redux'
import {connect} from 'react-redux'
import * as Actions from '../actions'

import Header from '../components/Header'
import Toaster from '../components/Toaster'
class App extends Component {
    constructor(props) {
        super(props)
    }



    render() {
        const {children,actions,msg,auth} = this.props;
        return (
            <div>
                <Header auth={auth} logout={actions.logout} getUserInfo={actions.getUserInfo} />
                {children}
                <Toaster msg={msg} hideMsg={actions.hideMsg}/>
            </div>
        )
    }
}

App.propTypes = {
    msg:PropTypes.object.isRequired,
    auth:PropTypes.object.isRequired,
    actions: PropTypes.object.isRequired,
    // Injected by React Router
    children: PropTypes.node,
    location: PropTypes.object
};

const mapStateToProps = (state) => {
    return {
        msg:state.msg,
        auth:state.auth
    }
};

const mapDispatchToProps = dispatch =>{
    return {
        actions: bindActionCreators(Actions, dispatch)
    }
};

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(App)